package org.shunfeng.controller;

import org.shunfeng.dao.DeliveryListDao;
import org.shunfeng.service.DeliveryListService;
import org.shunfeng.service.impl.DeliveryListServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/delivery/deleteDelivery")
public class DeleteDelivery extends HttpServlet {
    private DeliveryListService deliveryListService = new DeliveryListServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            req.setCharacterEncoding("utf-8");
            resp.setContentType("text/html;charset=utf-8");

            String id = req.getParameter("id");
            System.out.println("删除id = " + id);
            deliveryListService.deleteDelivery(id);
            resp.sendRedirect(req.getContextPath() + "/delivery/list");


        } catch (SQLException e) {
            throw new RuntimeException(e);
        }


    }
}
